package com.sdyeda.readiot.fx;

import com.sdyeda.readiot.iotinfo.IotData;
import com.sdyeda.readiot.iotinfo.IotInfo;

import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.control.ListView;
import javafx.scene.control.ProgressBar;
import javafx.stage.Stage;

public class ReadDialogController {
	
	private Stage stage;

	private IotInfo iotinfo;

	@FXML
	private ProgressBar pgbstep;

	@FXML
	private ListView<String> liststep;
	
	private DetailWindowController detailwindowcontroller = null;

	@FXML
	void initialize() {
		// txtstep.setText("ADS");
	}

	public void clearInfo() {
		Platform.runLater(() -> {
			liststep.getItems().clear();
			pgbstep.setProgress(0);
		});
	}

	public void setInfo(double progress, String info, int type) {

		Platform.runLater(() -> {
			liststep.getItems().add(info);
			pgbstep.setProgress(progress);
			liststep.refresh();
			liststep.scrollTo(liststep.getItems().size());
		});

	}
	
	public void diapReadData(IotData iotdata) {
		Platform.runLater(() -> {
			detailwindowcontroller.refushTvList(iotdata);
		});
	}
	

	public IotInfo getIotinfo() {
		return iotinfo;
	}

	public void setIotinfo(IotInfo iotinfo) {
		this.iotinfo = iotinfo;
	}

	public DetailWindowController getDetailwindowcontroller() {
		return detailwindowcontroller;
	}

	public void setDetailwindowcontroller(DetailWindowController detailwindowcontroller) {
		this.detailwindowcontroller = detailwindowcontroller;
	}

	public Stage getStage() {
		return stage;
	}

	public void setStage(Stage stage) {
		this.stage = stage;
	}
}
